<template>
  <div class="g-bd">
    <div class="box" v-show="isShowPro">
      <Program :programsLeft="programsLeft"></Program>
    </div>
    <div class="box" v-show="!isShowPro">
      <Rank :topList="topList"></Rank>
    </div>
  </div>
</template>
<script>
import Program from "@/components/ProgramList";
// const 方法的 组件懒加载
// const program = () => import("@/components/ProgramList");
import Rank from "@/components/RankList";
export default {
  data: () => ({
    isShowPro: true,
    programsLeft: [],
    topList: [],
  }),
  created() {
    if (this.$route.params.type == "list") {
      this.isShowPro = true;
      this.getProgrammRrecommend();
    }
    if (this.$route.params.type == "rank") {
      this.isShowPro = false;
      this.getProgrammRank();
    }
  },
  methods: {
    async getProgrammRrecommend() {
      const {
        data: { programs },
      } = await this.Api.wjwApi.getProgrammRrecommend();
      this.programsLeft = programs;
      // console.log(programs);
    },
    async getProgrammRank() {
      const {
        data: { toplist },
      } = await this.Api.wjwApi.getProgrammRank(100);
      const base = parseFloat(toplist[0].score / 0.92);
      toplist.forEach((item) => {
        item.width = (item.score / base) * 100 + "%";
      });
      this.topList = toplist;
      // console.log(toplist);
    },
  },
  components: {
    Program,Rank,
    // Program: program,
    // // 异步方法  组件懒加载
    // Rank: (resolve) => ["@/components/RankList", resolve],
  },
};
</script>
<style lang="less">
body,
textarea,
select,
input,
button {
  font-size: 12px;
  color: #333;
  font-family: Arial, Helvetica, sans-serif;
  -webkit-text-size-adjust: none;
}
h1,
h2,
h3,
h4,
h5,
h6 {
  font-size: 100%;
}
.g-bd,
.g-bd1,
.g-bd2,
.g-bd3,
.g-bd4,
.g-bd5,
.g-bd6,
.g-bd7 {
  width: 980px;
  min-height: 700px;
  _height: 700px;
  margin: 0 auto;
  background-color: #fff;
  border: 1px solid #d3d3d3;
  border-width: 0 1px;
}
.g-wrap {
  padding: 40px;
}
.u-title {
  height: 40px;
  border-bottom: 2px solid #c20c0c;
}
.f-pr {
  position: relative;
  zoom: 1;
}
.f-cb:after {
  clear: both;
  content: ".";
  display: block;
  height: 0;
  visibility: hidden;
}
.u-title h3 {
  float: left;
  font-size: 24px;
  font-weight: normal;
}
.f-ff2 {
  font-family: "Microsoft Yahei", Arial, Helvetica, sans-serif;
}
.u-title .sub {
  float: left;
  margin: 13px 0 0 10px;
}
.s-fc4,
a.s-fc4:hover {
  color: #999;
}
.toplist-rank,
.toplist-recmd {
  height: auto;
}
.toplist {
  border: 1px solid #e2e2e2;
  border-top: none;
}

.toplist .itm {
  width: 424px;
  height: 40px;
  padding: 10px 0;
  line-height: 40px;
}
.m-plylist .itm {
  float: left;
  width: 100%;
  background: #fff;
}
.toplist-rank .itm,
.toplist-recmd .itm {
  width: 100%;
}
.toplist .itm:nth-child(2n) {
  background: #f7f7f7;
}
.m-plylist .col {
  float: left;
  margin-left: 10px;
}
.u-cover-tiny {
  width: 40px;
  height: 40px;
}
.u-cover {
  position: relative;
  display: block;
}
a,
a *,
.f-hand,
.f-hand * {
  cursor: pointer;
}
a {
  text-decoration: none;
  color: #333;
}
.u-cover img {
  display: block;
  width: 100%;
  height: 100%;
}
.u-cover-tiny .ply {
  position: absolute;
  display: none;
  width: 22px;
  height: 22px;
  top: 50%;
  left: 50%;
  overflow: hidden;
  background: url("../../../../assets/wjwimgs/iconall.png") no-repeat;
  margin: -11px 0 0 -11px;
  background-position: 0 -85px;
}
.toplist .itm:hover {
  background: #e0e0e0;
  .u-cover-tiny .ply {
    display: block;
  }
}

.f-thide {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  word-wrap: normal;
}
.m-plylist .col {
  float: left;
  margin-left: 10px;
}
.toplist-rank .cnt,
.toplist-recmd .cnt {
  width: 304px;
  margin: 0 0 0 10px;
  line-height: 40px;
}
.s-fc1 {
  color: #333;
}
.m-radio .toplist-recmd .artist {
  width: 166px;
}
.m-plylist .col {
  float: left;
  margin-left: 10px;
}
.s-fc3 {
  color: #666;
}
.s-fc3:hover,
.s-fc1:hover {
  text-decoration: underline;
}
.m-radio .toplist-recmd .col-4 {
  width: 90px;
}
.m-plylist .col {
  float: left;
  margin-left: 10px;
}
.s-fc4,
a.s-fc4:hover {
  color: #999;
}
.m-radio .toplist-recmd .col-5 {
  width: 126px;
}
.m-radio .toplist .tag {
  margin: 1px 0 0 10px;
  _margin-top: 9px;
}
.u-type {
  display: inline-block;
  position: relative;
  top: -1px;
  height: 16px;
  overflow: hidden;
  padding: 0 6px;
  border: 1px solid #999;
  line-height: 16px;
  *line-height: 18px;
  color: #999;
  vertical-align: middle;
  font-size: 12px;
}
.u-type:hover {
  border-color: #666;
  color: #666;
}
.u-title .info {
  bottom: 9px;
  right: 0;
  width: 18px;
  height: 18px;
}
.f-pa {
  position: absolute;
}
.u-icn,
.u-icn2,
.u-icn3 {
  display: inline-block;
  overflow: hidden;
  vertical-align: middle;
}
.u-icn2 {
  background: url("../../../../assets/wjwimgs/icon2.png") no-repeat 0 9999px;
}
.u-icn2-5 {
  width: 18px;
  height: 18px;
  background-position: 0 -50px;
}
.u-title .info .tip {
  background: url("../../../../assets/wjwimgs/tip.png");
}
.u-title .info .tip {
  display: none;
  top: 13px;
  right: -41px;
  width: 295px;
  height: 43px;
  padding: 24px 19px 19px 19px;
  line-height: 20px;
  z-index: 9999;
}
.info:hover {
  .tip {
    display: block;
  }
}
.m-radio .toplist .rank {
  width: 47px;
  margin: 6px 0 0 0;
  text-align: center;
  line-height: normal;
}
.m-plylist .col {
  float: left;
  margin-left: 10px;
}
.s-fc4,
a.s-fc4:hover {
  color: #999;
}
.m-radio .toplist .rank .red {
  color: #da4545;
}
.m-radio .toplist .rank em {
  display: block;
  width: 100%;
  text-align: center;
  font-size: 14px;
}
.f-fs1 {
  font-size: 14px;
}
.u-rnk {
  line-height: normal;
  font-size: 10px;
}
.f-ff0 {
  font-family: Arial, Helvetica, sans-serif;
}
.u-rnk i {
  margin: -1px 2px 0 0;
  vertical-align: middle;
}
.u-icn,
.u-title-1 .out .icon {
  background: url("../../../../assets/wjwimgs/icon.png") no-repeat 0 9999px;
}
.u-icn-72,
.u-icn-73,
.u-icn-74 {
  width: 6px;
  height: 6px;
  background-position: -74px -274px;
}
.u-icn,
.u-icn2,
.u-icn3 {
  display: inline-block;
  overflow: hidden;
  vertical-align: middle;
}
.m-radio .toplist-rank .cvr {
  margin: 0;
}
.m-radio .toplist-rank .artist {
  width: 176px;
}
.u-hot,
.u-hot i {
  background: url("../../../../assets/wjwimgs/table.png") no-repeat 0 9999px;
}
.u-hot {
  position: relative;
  width: 100px;
  background-position: 0 -240px;
  line-height: normal;
}
.u-hot,
.u-hot i {
  display: block;
  height: 8px;
}
.m-radio .toplist-rank .tag {
  width: 140px;
}
.m-radio .toplist-rank .hot {
  margin-left: 28px;
}
.m-radio .toplist .hot {
  margin-top: 16px;
}
.m-plylist .col {
  float: left;
  margin-left: 10px;
}
.u-hot i {
  overflow: hidden;
  padding: 0 4px;
  background-position: right -318px;
}
.u-hot i i {
  margin-left: -4px;
  padding: 0 0 0 4px;
  background-position: 0 -304px;
}
.u-rnk {
  line-height: normal;
  font-size: 10px;
  font-family: Arial, Helvetica, sans-serif;
  .u-icn {
    background: url("../../../../assets/wjwimgs/icon.png") no-repeat 0 9999px;
    margin: -1px 2px 0 0;
    width: 6px;
    height: 6px;
    background-position: -74px -274px;
    display: inline-block;
    overflow: hidden;
  }
  .u-icn-new {
    width: 16px;
    height: 17px;
    background-position: -67px -283px;
  }
}
.itm .u-rnk-up {
  color: #ba2226;
  .u-icn {
    background-position: -74px -304px;
  }
  .u-icn-new {
    width: 16px;
    height: 17px;
    background-position: -67px -283px;
  }
}
.itm .u-rnk-dn {
  color: #4abbeb;
  .u-icn {
    background-position: -74px -324px;
  }
  .u-icn-new {
    width: 16px;
    height: 17px;
    background-position: -67px -283px;
  }
}
</style>
